package AndroidHT.Workspace;


import domain.Gps;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.TextView;
import android.widget.Toast;
import AndroidHT.Workspace.R;


public class AndroidHTActivity extends Activity {
    /** Called when the activity is first created. */
	private int CantidadAct;
	private String Imei;
	private String Email;
		
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
    	final Context cont = this;
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        SharedPreferences settings = getSharedPreferences("HT",MODE_PRIVATE);
        TextView txtHello = (TextView) findViewById(R.id.hello);
        txtHello.setText("Version = 3.0");
        if(!settings.contains("HT_Email"))
        {
        	startActivity(new Intent(cont,WelcomeActivity.class));
        }
        
        Intent myIntent = new Intent(cont, HTService.class);  
        startService(myIntent);
    	
            
        /*
        Email = Settings.getString("HT_Email","Not defined");
          
        TextView txtHello = (TextView) findViewById(R.id.hello);
        Gps gpsHandlerByGpsProvider = new Gps();
        Gps gpsHandlerByNetworkProvider = new Gps();
        
        gpsHandlerByGpsProvider.loadActivity(this);
        gpsHandlerByNetworkProvider.loadActivity(this);
        
        LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 1.0f, gpsHandlerByGpsProvider);
        lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000L, 1.0f, gpsHandlerByNetworkProvider);
        Imei = tm.getDeviceId();
        txtHello.setText("Version = 2.4");
        */
       
	    
        
    }
    
    public void updateCoordinates(Gps gpsHandlerParam)
    {
    	   TextView cantLat = (TextView) findViewById(R.id.CantidadAct);
    	   TextView textAltitud = (TextView) findViewById(R.id.Altitud);
    	   TextView textVelocidad = (TextView) findViewById(R.id.Velocidad);
           TextView textLat = (TextView) findViewById(R.id.textView1);
           TextView textLong = (TextView) findViewById(R.id.textView2);
           TextView textImei = (TextView) findViewById(R.id.imei);
           
           textLat.setText("Latitud = "+gpsHandlerParam.GetLatitud());
           textLong.setText("Longitud = "+gpsHandlerParam.GetLongitud());
           textAltitud.setText("Altitud = "+gpsHandlerParam.GetAltitud());
           textVelocidad.setText("Velocidad = "+gpsHandlerParam.GetVelocidad());
           textImei.setText("IMEI = "+this.Imei+" Mail = "+Email);
           cantLat.setText("Cantidad de Act ="+CantidadAct);
           CantidadAct++;   
    }

	public String getImei() {
		return Imei;
	}
	
	public String getMail() {
		return Email;
	}
}